#ifndef _CSP_SHARED_TYPES_H_ 
#define _CSP_SHARED_TYPES_H_

#include <csp_macros.h>

#include <vec_types.h>
#include <stdint.h>

#define CHANNEL_SUCCESS 0
#define CHANNEL_POISON -1


typedef uint32_t         ls_addr_t;   /**< LS address type (32-bit) */
typedef uint32_t         ls_size_t;   /**< LS size type (32-bit) */
typedef uint32_t         ea_addr_t;   /**< EA address type (64-bit) */
typedef uint32_t         ea_size_t;   /**< EA size type (64-bit) */

typedef struct spe_args{
	ea_addr_t	process_data_EA;
	uint32_t	spe_id;
	ea_addr_t	offload_area_ea;
	ea_addr_t	pcb_head;
	ea_addr_t	shared_addr;
	char     dummy[108];
} spe_args_t __attribute__ ((aligned(16)));

typedef struct pcb{
	volatile unsigned char dma_completion_flag[2]; /* this must be first! */
	/* For loading */	
	ls_addr_t stack_start;
	ls_size_t bss_size;
	ls_size_t heap_size;
	ea_addr_t exec;
	ls_size_t exec_size;
	ls_addr_t vaddr;
	ls_addr_t entry;
	unsigned char slot;

	ea_addr_t ea_store;
	ls_size_t stack_size;

	int32_t pid;
	ls_addr_t state;
	int32_t ret_val; /* Process return val */
	int32_t op_ret_val; /* Return value of a syscall. */

	int32_t misc_val;

	ea_addr_t dma_completion_flag_ea_addr;

	ea_addr_t channel_data;

	ea_addr_t pcb_ea;

	/* padding */
	char dummy[51];
} pcb_t __attribute__ ((aligned(16)));


typedef struct _csp_channel{
	int32_t op; 
	uint32_t type; 
	int64_t id; 
	ls_addr_t addr; 
	uint32_t nbytes;
	char dummy[104];
} csp_channel_t __attribute__ ((aligned(16)));

typedef struct _csp_guard_list{
	ls_size_t size;
	csp_channel_t *head; 
} csp_guard_list_t;



#endif
